<?php 
include('../connection/connection.php');
include('../config.php');
include('../header.php');
include('../menu.php');

?>

<!DOCTYPE HTML>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="animatedcollapse.js"></script>
<script type="text/javascript">
animatedcollapse.addDiv('q1andq2','fade=0,speed=0,group=pets,hide=1')
animatedcollapse.addDiv('q3','fade=0,speed=400,group=pets,hide=1')

animatedcollapse.ontoggle=function($, divobj, state){ //fires each time a DIV is expanded/contracted
	//$: Access to jQuery
	//divobj: DOM reference to DIV being expanded/ collapsed. Use "divobj.id" to get its ID
	//state: "block" or "none", depending on state
}
animatedcollapse.init()
</script>

<script>
function Inint_AJAX() 
{
	try 
	{ 
		return new ActiveXObject("Msxml2.XMLHTTP");  
	} 
	catch(e) 
	{} //IE
	try 
	{ 
		return new ActiveXObject("Microsoft.XMLHTTP"); 
	} 
	catch(e) {} //IE
	try 
	{ 
		return new XMLHttpRequest(); 
	} catch(e) {} //Native Javascript
	alert("XMLHttpRequest not supported");
	return null;
};
function loadReport(reportName)
{
	document.getElementById('reportDiv').innerHTML="<img src='../images/ajax-loader-big.gif' alt='My Loader' />";
	//document.getElementById('reportDiv').innerHTML=" ";
	//document.getElementById('reportDiv').style.display="none";
	
	var val=document.getElementById('district').value;
	if(val){	
	
	url=reportName+".php?distId="+val;
	//alert(url);
	
	var req = Inint_AJAX();
	req.onreadystatechange = function () 
	{ 
		
		//document.getElementById('reportDiv').innerHTML=" ";
		//document.getElementById('reportDiv').innerHTML="<img src='../images/ajax-loader-big.gif' alt='My Loader' />";
		if (req.readyState==4)
		{
			if (req.status==200) 
			{
				

				animatedcollapse.hide('q1andq2');
				animatedcollapse.hide('q3');
				
				//alert(req.responseText);
				document.getElementById('reportDiv').innerHTML=req.responseText;
				//document.getElementById('reportDiv').innerHTML+="<br><a href='' onClick='return PrintContent()'>Print this Report</a>";
				//document.getElementById('reportDiv').style.display="block";
				//animatedcollapse.hide('reportDiv');
			} 
		}
	};
	req.open("post", url); 
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=tis-620"); // set Header
	req.send(null); 
	}
	else {
	alert("Please select any district");
	}
}


function PrintContent()
{
var DocumentContainer = document.getElementById('reportDiv');
var WindowObject = window.open("PrintWindow",width=750,height=650,top=50,left=50,toolbars='no',scrollbars='yes',status='no',resizable='yes');
WindowObject.document.writeln(DocumentContainer.innerHTML);
WindowObject.document.close();
WindowObject.focus();
WindowObject.print();
WindowObject.close();
}
	

</script>

<body><center>
<div style="display:none">
<select name="district" id="district">
<option value=""><font face="Verdana" style="font-size: 9pt; font-weight: 700" color="#224568">Select District</font></option>
<?php
$qry="select DISTINCT district_id, district_name from tbl_lookup_location order by district_name";
//echo $qry;
$result=mysql_query($qry);
while(list($id, $name)=mysql_fetch_array($result))
{
    ?><option value="<?php echo $id ?>" <?php if($id==418){echo 'selected';} ?>><font face="Verdana" style="font-size: 9pt; font-weight: 700" color="#224568"><?php echo $name; ?></font></option>
	<?php
}  
?>
</select>
</div>

<!--<p><b>Report List From Questionnaire1 and Questionnaire2</b></p>-->
<br><br><!--<a href="#" rel="toggle[q1andq2]" data-openimage="collapse.jpg" data-closedimage="expand.jpg" ><img src="collapse.jpg" border="0" /></a>--> <a href="javascript:animatedcollapse.show('q1andq2')">MIS Report</a> || <a href="javascript:animatedcollapse.hide('q1andq2')">Slide Up</a><br><br>
<div id="q1andq2" style="width: 800px ; background: #BDF381;">



<table width="795" border="1">
  <tr>
    <td colspan="2"><div align="center"><strong>MIS Report</strong></div></td>
    </tr>
	<?php 
	$i=1;
	foreach($misreportList_q1_q2 as $rl)
	{
	?>
  <tr>
    <td width="69"><font style="font-size: 8.5pt" face="Verdana">Table <?php echo $i; $reportName="report".$i;?> </font></td>
    <td width="710"><a href="#" onClick="loadReport('<?php echo $reportName ;?>')"><font style="font-size: 8.5pt" face="Verdana"><?php echo $rl;?></font></a></td>
  </tr>
  <?php
  $i++;
  }
  ?>
 
</table>
</div>

<br>
<div id="reportDiv"></div>


</body></center>